#include "eeprom.h"

#include "i2c_hal.h"

void EEPROM_WriteByte(uint8_t addr, uint8_t data)
{
    I2CStart();
    I2CSendByte(0xA0);
    I2CWaitAck();
    I2CSendByte(addr);
    I2CWaitAck();
    I2CSendByte(data);
    I2CWaitAck();
    I2CStop();
}

uint8_t EEPROM_ReadByte(uint8_t addr)
{
    uint8_t ret_val = 0;

    I2CStart();
    I2CSendByte(0xA0);
    I2CWaitAck();
    I2CSendByte(addr);
    I2CWaitAck();
    I2CStart();
    I2CSendByte(0xA1);
    I2CWaitAck();
    ret_val = I2CReceiveByte();
    I2CSendNotAck();
    I2CStop();

    return ret_val;
}
